import { fileURLToPath, URL } from "node:url";

import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import svgLoader from "vite-svg-loader";
// import { loadEnv as myLoadEnv } from './loadEnv.js'

// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
  // const env = loadEnv(mode, process.cwd());
  // myLoadEnv(mode)
  return {

    plugins: [vue(), svgLoader()],
    envPrefix:"APP_", //配置环境变量的前缀
    resolve: {
      alias: {
        "@": fileURLToPath(new URL("./src", import.meta.url)),
        '@antv/x6': '@antv/x6/lib',
        '@antv/x6-vue-shape': '@antv/x6-vue-shape/lib',
        // 'vue': 'vue/dist/vue.esm-bundler.js'
      },
    },
    server: {
      host: '0.0.0.0',
      proxy: {
        // string shorthand: http://localhost:5173/foo -> http://localhost:4567/foo
        // '/english': 'http://localhost:8000',
        "/api": "http://localhost:8001",
        "/upload": "http://localhost:8001",
      },
    },
    // define: {
    //   'process.env': env,
    // },
  };
});
